function sieve(a) {
  // let a = new Uint8Array(n + 1);
  let n = a.length - 1;
  let max = Math.floor(Math.sqrt(n));
  let p = 2;
  while (p <= max) {
    for (let i = 2 * p; i <= n; i += p) a[i] = 1;
    while (a[++p] /* 空循环 */);
  }
  while (a[n]) n--;
  return n;
}
console.time("use");
console.log(sieve(new Uint8Array(100000000))); // 耗时 974.045 ms
// console.log(sieve(new Array(100000000))); // 耗时 7101 ms
// 速度快7.3倍
console.timeEnd("use");
